/**
 * @Author ZhangCuirong
 * @Date 2025/9/8 13:52
 * @description:
 */
public class Solution125 {
    public boolean isPalindrome(String s) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c >= 'A' && c <= 'Z') {
                sb.append((char)('a' + (c - 'A')));
//                sb.append(Character.toLowerCase(c));
            } else if ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')) {
                sb.append(c);
            }
        }
        if (sb.length() == 0) {
            return true;
        }
        int left = 0, right = sb.length() - 1;
        while (left <= right) {
            if (sb.charAt(left) != sb.charAt(right)) {
                return false;
            }
            left++;
            right--;
        }
        return true;
    }

    public static void main(String[] args) {
        Solution125 solution = new Solution125();
        System.out.println(solution.isPalindrome("A man, a plan, a canal: Panama"));
    }
}
